function FV_weizmann_training(Ncent)
%%Calcular FV for all videos

%NICTA && Server
%addpath('/home/johanna/toolbox/yael/matlab');

%Home
%addpath('/media/johanna/HD1T/Toolbox/yael/matlab');

fprintf('Ng %d \n',Ncent);

for r=1:9
    run = int2str(r);
    Ng = int2str(Ncent);
    dim = int2str(14);
    fprintf('RUN %s \n',run);
    
    w  =    load(strcat('./run', run, '/universal_GMM/weights_Ng', Ng, '_dim', dim ));
    mu =    load(strcat('./run', run, '/universal_GMM/means_Ng'  , Ng, '_dim', dim ));
    sigma = load(strcat('./run', run, '/universal_GMM/covs_Ng'   , Ng, '_dim', dim ));
    
    people_train = importdata(strcat('./run',run,'/train_list_run',run,'.dat'));
    actionNames = importdata('actionNames.txt');
    
    
    n_people  = length(people_train);
    n_actions = length(actionNames);
    
    for i=1:n_people
        for j=1:n_actions
            name_feat = strcat('./features_training/feat_vec_', people_train{i},'_',actionNames{j});
            
            S = char(name_feat);
            data_onevideo = load(S);
            one_video = {data_onevideo};
            
            v = compute_fisher_joha (single(w), single(mu), single(sigma), one_video);
            d_fisher = size (v, 1);              % dimension of the Fisher vectors
            
            % power "normalisation"
            v = sign(v) .* sqrt(abs(v));
            
            %L2 normalization (may introduce NaN vectors)
            vn = yael_fvecs_normalize (v);
            
            % replace NaN vectors with a large value that is far from everything else
            % For normalized vectors in high dimension, vector (0, ..., 0) is *close* to
            % many vectors.
            %vn(find(isnan(vn))) = 123;
            
            if ( length( find( isnan(vn) ) )> 0 )
                disp('Que hago??????');
                
            end
            %to save
            
            save_name = strcat('./run',run,'/FV_training/FV_', people_train(i),'_',actionNames(j), '_Ng', Ng, '.txt');
            sSave = char(save_name);
            %display(sSave);
            fid1=fopen(sSave,'wt');
            fprintf(fid1,'%8.8f\n',vn);
            fclose(fid1);
            
            %save(sSave, 'vn', '-ascii');
            
        end
        
    end
end
